home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Instance.sea / XML Instance / Required / plugins / HTMLWindow.jar / horst / ListView.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-03-18  |  2.1 KB  |  54 lines

  1. package horst;
  2.  
  3. import java.awt.Font;
  4. import java.awt.FontMetrics;
  5. import java.awt.Toolkit;
  6.  
  7. class ListView extends BlockView {
  8.    ListView(View parent, Element e, HTMLPane container) {
  9.       super(parent, e, container);
  10.    }
  11.  
  12.    protected void init() {
  13.       ((View)this).setInsets(0, 15, 0, 0);
  14.    }
  15.  
  16.    protected boolean isWrappable() {
  17.       return true;
  18.    }
  19.  
  20.    protected void makeChildren(ViewFactory factory) {
  21.       super.makeChildren(factory);
  22.       if (super.m_elem.getType() == 23 && super.m_children != null) {
  23.          int orderNum = 1;
  24.          String start = (String)super.m_elem.getAttribute("start");
  25.          if (start != null) {
  26.             Integer iVal = Utilities.getInteger(start);
  27.             if (iVal != null && iVal > 0) {
  28.                orderNum = iVal;
  29.             }
  30.          }
  31.  
  32.          int maxNumberWidth = 0;
  33.  
  34.          for(int i = 0; i < super.m_children.length; ++i) {
  35.             if (super.m_children[i] instanceof ListItemView) {
  36.                Font f = super.m_children[i].getFont();
  37.                FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f);
  38.                maxNumberWidth = Math.max(fm.stringWidth(String.valueOf(orderNum)), maxNumberWidth);
  39.                ((ListItemView)super.m_children[i]).setOrderNumber(orderNum++);
  40.             }
  41.          }
  42.  
  43.          maxNumberWidth += 6;
  44.  
  45.          for(int i = 0; i < super.m_children.length; ++i) {
  46.             if (super.m_children[i] instanceof ListItemView) {
  47.                ((ListItemView)super.m_children[i]).setLeftInset(maxNumberWidth);
  48.             }
  49.          }
  50.       }
  51.  
  52.    }
  53. }
  54.